<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * 权限管理Model
 */
class Power_mdl extends CI_Model{

    const TABLE = 'power';

    /**
     * 查询所有权限（去除基本权限）
     * @return array
     */
    public function power_all($map){
        foreach($map as $k => $v){
            $this->db->where($k,$v);
        }
        $query = $this->db->get(self::TABLE);
        //echo $this->db->last_query();
        return $query->result_array();
    }

    /**
     * 添加权限
     */
    public function create($data){
        return $this->db->insert(self::TABLE,$data);
    }

    /**
     * 根据ID查询单条数据
     */
    public function get_one($id){
        $this->db->where('id',$id);
        $query = $this->db->get(self::TABLE);
        return $query->row_array();
    }
	
	/**
	 * 修改
	 */
	public function update($data,$map){
		foreach($map as $k => $v){
			$this->db->where($k,$v);
		}
		return $this->db->update(self::TABLE,$data);
	}
	
	/**
	 * 删除
	 */
	public function delete($tmp){
		foreach($tmp as $k => $v){
			$this->db->where($k,$v);
		}
		$v = $this->db->delete(self::TABLE);
		
		return $v;
	}
}